<template>
	<view class="container-box" v-for="(item,i) in this.info" :key="i">
		<view class="item-box" @click="onTopDetail(item)">
			{{item}}
		</view>
	</view>
</template>

<script>
	import service from '../../utils/http.js'
	export default {
		data() {
			return {
				info: {},
				result:{}
			};
		},
		onLoad() {
			this.getTopSearch()
		},
		methods: {
			getTopSearch() {
				service.get('/api/common/HotList')
					.then(response => {
						if (response.code === 200) {
							const result = response.result
							this.result=result
							this.info = Object.keys(result).filter(key => Array.isArray(result[key]));						
						}
					})
					.catch(error => {
						console.error(error);
					});
			},
			onTopDetail(item){
				uni.navigateTo({
					url:'/subpkg/topdetail/topdetail?title='+item
				})
			}
		}
	}
</script>

<style lang="scss">
	.container-box {
		display: flex;
		.item-box {
			width: 150px;
			height: 25px;
			border: 1px solid lightgray;
			text-align: center;
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
		}
	}
</style>